import xlrd
import xlwt
import jieba.posseg as pseg

if __name__ == '__main__':
    count = 0
    rbook = xlrd.open_workbook(r'C:\Users\da\Desktop\test.xls')
    rbook.sheets()
    rsheet = rbook.sheet_by_index(0)

    wbk = xlwt.Workbook()
    sheet = wbk.add_sheet('sheet 1')

    for row in rsheet.get_rows():
        if row[0].value != '':
            words = pseg.cut(row[0].value)
            result = ""

            for x in words:
                if x.flag != 'eng' and x.flag != 't' and x.flag != 'x':
                    result = result + str(x.word) + "\\" + str(x.flag) + " "
            print(result)

            # for w in words:
            # result = result + str(w.word) + "/" + str(w.flag)+" "

    # for row in rsheet.get_rows():
    #     if row[3].value != '市场售价':
    #         if row[3].value != '':
    #             sheet.write(count, 0, str(int(row[3].value) + 20))
    #             sheet.write(count, 1, str(int(row[3].value) + 10))
    #         else:
    #             sheet.write(count, 0, "")
    #             sheet.write(count, 1, "")
    #     count = count + 1
    # wbk.save(r'C:\Users\da\Desktop\test.xls')
